#include<bits/stdc++.h>
#define re return
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define int ll
#define forn(i,a,n) for(int i=a;i<n;i++)
#define sz(s) (int)(s.size())
#define pii pair<int,int>
#define fr first
#define se second
#define vi vector<int>
using namespace std;
int t;
int n,m,l,v;
const int maxn=1e5+10;
int d[maxn],cv[maxn],a[maxn];
int p[maxn];
int ans;
int mxl[maxn];
int dp[maxn];
int s[maxn],hd,tl;
void upd(int xl,int xr){
    xr=min(xr,l);
    if(xl>xr)
    re;
    int posl=lower_bound(p,p+m,xl)-p,posr=upper_bound(p,p+m,xr)-p;
    if(posl==posr)
    re;
    ans++;
    posl++;
    mxl[posr]=max(mxl[posr],posl);
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>v;
        rep(i,n)
        cin>>d[i]>>cv[i]>>a[i];
        rep(i,m)
        cin>>p[i];
        rep(i,m+1)
        mxl[i]=0;
        ans=0;
        rep(i,n){
            if(a[i]==0){
                if(cv[i]<=v)
                continue;
                upd(d[i],l);
            }
            if(a[i]>0){
                if(cv[i]<=v)
                upd((v-cv[i])*(v+cv[i])/(2*a[i])+1+d[i],l);
                else
                upd(d[i],l);
            }
            if(a[i]<0){
                if(cv[i]<=v)
                continue;
                upd(d[i],((cv[i]-v)*(v+cv[i])+(-2*a[i])-1)/(-2*a[i])-1+d[i]);
            }
        }
        cout<<ans<<" ";
        forn(i,1,m+1)
        mxl[i]=max(mxl[i],mxl[i-1]);
        dp[0]=0;
        hd=tl=0;
        s[tl++]=0;
        // cout<<mxl[m]<<"\n";
        forn(i,1,m+1){
            dp[i]=dp[s[hd]]+1;
            // cout<<s[hd]<<"\n";
            while(tl>hd&&dp[s[tl-1]]>dp[i])
            tl--;
            s[tl++]=i;
            while(s[hd]<mxl[i])
            hd++;
            // cout<<hd<<" "<<tl<<"\n";
        }
        cout<<m-dp[s[hd]]<<"\n";
    }
    re 0;
}